#include <fstream>
#include <iostream>
#include "computer_lab.h"
#include "global_const.h"
ComputerLab::ComputerLab()
{
}

ComputerLab::ComputerLab(int id, int cap)
{
    this->m_id = id;
    this->m_capacity = cap;
}

void init_lab()
{
    std::ofstream ofs(COMPUTER_LAB_FILE, std::ios::trunc | std::ios::out);
    ofs << "1 20" << std::endl;
    ofs << "2 50" << std::endl;
    ofs << "3 100" << std::endl;
    ofs.close();
}
void show_lab()
{

    std::cout << "-------------------------" << std::endl;
    std::ifstream ifs(COMPUTER_LAB_FILE, std::ios::in);
    if (!ifs.is_open())
    {
        std::cout << "机房信息不存在" << std::endl;
        std::cout << "-------------------------" << std::endl;
        return;
    }
    int id;
    int cap;
    while (ifs >> id && ifs >> cap)
    {
        std::cout << "机房: " << id << " 容量: " << cap << std::endl;
    }
    std::cout << "-------------------------" << std::endl;
    ifs.close();
}
